<template>
	<view class="warp">
		<view class="list">
			<view @click="choose(item,index)" class="item" v-for="(item,index) in shoplist" :key="index">
				<view class="left">
					<view class="icon">
						
						<uni-icons color="#4ae979" v-if="item.show"  type="checkmarkempty" size="25"></uni-icons>
						<uni-icons v-else type="circle" size="18"></uni-icons>
					</view>
					<view class="deptname">
						{{item.vendor_name}}
					</view>
				</view>
			</view>
		</view>
		<view class="submit">
			<view class="button" @click="submit">
				确认
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				shoplist:[
					
				],
				chooselinst:[]
			};
		},
		onLoad() {
			this.getshoplist()
		},
		methods:{
			// 获取店铺列表
			getshoplist(){
				this.$request({
					url:'v3/seller/front/vendor/member/list'
				}).then(res=>{
					this.shoplist=res.data.list
					this.shoplist.forEach(item=>{
						item.show=false
					})
				})
			},
			// 选中
			choose(val,idx){
				if(val.show==false){
					val.show=true
					this.$set(this.shoplist,idx,val)
					
					this.chooselinst.push({userName:val.vendor_name,userId:val.member_id,storeImage:val.store_logo,storeId:val.store_id})
					
				}else{
					val.show=false
					this.$set(this.shoplist,idx,val)
					this.chooselinst.forEach((item,index)=>{
						if(item.member_id==val.member_id){
							this.chooselinst.splice(index,1)
						}
					})
					
				}
			},
			// 确认
			submit(){
				let that = this;
				let pages = getCurrentPages();
				let prevPage = pages[pages.length - 2]; //上一个页面
				prevPage.$vm.shoplist=that.chooselinst
				this.$Router.back(1)
			}
		}
	}
</script>

<style lang="scss" scoped>
page{
			width: 750rpx;
			margin: 0 auto;
			background: #F5F5F5;
			overflow: hidden;
		}
		.warp{
			margin-top: 10rpx;
			.list{
				.item{
					padding: 30rpx;
					display: flex;
					justify-content: space-between;
					align-items: center;
					background-color: #fff;
					.left{
						display: flex;
						.deptname{
							margin-left: 10rpx;
						}
					}
				}
			}
			.submit{
			  position: fixed;
			  bottom: 10rpx;
			  left: 30%;
			  .button{
				  width: 300rpx;
				  height: 70rpx;
				  line-height: 70rpx;
				  background-color: #ff841f;
				  text-align: center;
				  color: #fff;
				  font-size: 32rpx;
				  border-radius: 35rpx;
			  }
			}
		}
</style>
